import {getAccount, postAccount, putAccount} from '@/base/api/AccountApi';
import {Account} from '@/base/model/Account';
import {getBanners, postBanner,putbanner} from "@/base/api/BannersApi";
import {Page} from "@/base/Page";
import {Company} from "@/base/model/Company";
import {getAgentList} from "@/base/api/AgentApi";
import {deepAssign} from "@/base/util/Objects";
import {getCompanyList} from '@/base/api/CompanyApi';
import {editBenefits, getBenefits} from "@/base/api/BenefitApi";
import {getMaintainDetail, getMaintainList} from "@/base/api/ServiceApi";
import {MainTain} from "@/base/model/MainTain";


export class MaintainBloc {
  model: any = {
    address : '',
    name : '',
    phone: 0,
    images : '',
    video : '',
    PM:'', // 设备型号
    buyTime:'', // 购买日期
    applyTime: '', //申请时间
    SN:'', // 设备序列号
    state:"",
    description:'',
    id:"",
    aid:"",
    describe:''
  };
  loading = false;
  fileList: Array<any> = [];
  num: number = 0;
  videoList: Array<any> = [];
  // sortId: number = 0;
  // modelId: number = 0;
  isDetail = false;
  i = false;
  hasFormInfo = false;

  load(id: number,aid: number) {
    return getMaintainDetail({id,aid})
      .then((res) => {
        // @ts-ignore
        let json = JSON.parse(res.data);
        this.model.address = json.errMsg.address.address;
        this.model.name = json.errMsg.address.name;
        this.model.phone= json.errMsg.address.phone;
        this.model.images = json.errMsg.images;
        this.model.video = json.errMsg.video;
        // this.model.images.map(x=>this.fileList.push(x));
        // this.model.video.map(x=>this.videoList.push(x));
        return res;
      }).finally(() => {
        this.hasFormInfo = true;
      })
  }

  // getMaintainList(pageIndex: number,
  //               pageSize: number,
  //               sortDirection: string) {
  //   return getMaintainList({pageIndex, pageSize, sortDirection,type:0,phone:13957370521 ,name: '', createBegin: ''})
  //     .then((res) => {
  //       deepAssign(this.maintain, res.data);
  //       console.log(this.maintain);
  //       return res;
  //     }).finally(() => {
  //       this.loading = false;
  //     });
  // }

}
